import axios from 'axios';

export async function setProxy(newProxy) {
  try {
    await axios.post('http://172.20.212.99:3000/api/set-proxy', { newProxy });
    localStorage.setItem('VITE_API_BASE_URL', newProxy);
    window.location.reload();
  } catch (error) {
    console.error('Failed to set proxy:', error);
  }
}

export function getProxy() {
  return localStorage.getItem('VITE_API_BASE_URL') || import.meta.env.VITE_API_BASE_URL;
}
